home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / DB_CLIPP / 2510.ZIP / TRSOURCE.EXE / BOQTR.C < prev    next >
C/C++ Source or Header  |  1990-10-22  |  847b  |  39 lines

  1. /*********
  2. *
  3. * BOQTR.C
  4. *
  5. * by Tom Rettig
  6. *
  7. * Placed in the public domain by Tom Rettig Associates, 10/22/1990.
  8. *
  9. * Syntax: BOQTR( <expD> )
  10. * Return: <expD> date of first day of <date>'s calendar quarter
  11. *********/
  12.  
  13. #include "trlib.h"
  14.  
  15. TRTYPE boqtr()
  16. {
  17.    int month;
  18.    char *ds;
  19.  
  20.    if ( PCOUNT == 1 && ISDATE(1) )
  21.    {
  22.       ds = _pards(1);
  23.       month = DSMONTH(ds);         /* Extract month from date string */
  24.       month = (((month - 1) / 3) * 3) + 1;  /* Takes month down
  25.                                                to nearest multiple of 3, +1 */
  26.  
  27.       ds[4] = (month / 10) + '0';    /* Convert to ASCII */
  28.       ds[5] = (month % 10) + '0';
  29.       ds[6] = '0';                   /* Quarter always begins on the 1st */
  30.       ds[7] = '1';
  31.  
  32.       _retds( ds);
  33.    }
  34.    else
  35.       _retds( BLANKDS );
  36. }
  37.  
  38.  
  39.